/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.hbrs.ooka.crs.servlet;

import de.hbrs.ooka.beans.ConferenceBeanStatelessLocal;
import de.hbrs.ooka.beans.PaperBeanStatelessLocal;
import de.hbrs.ooka.crs.servlet.constants.WebPageNames;
import de.hbrs.ooka.entities.ConferenceEntity;
import de.hbrs.ooka.entities.PaperEntity;
import de.hbrs.ooka.enums.Role;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author student
 */
public class MainServlet extends HttpServlet {
    
    @EJB
    private ConferenceBeanStatelessLocal conferenceBean;
    
    @EJB
    private PaperBeanStatelessLocal paperBean;
    
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        
        String action = request.getParameter("action");
        
        String redirect = WebPageNames.LoginViewPage;
        
        if( action == null){
            redirect = WebPageNames.LoginViewPage;
        } else {                    
            if(action.equalsIgnoreCase("participant")){
                redirect = WebPageNames.ParticipantViewPage;
            } else if(action.equalsIgnoreCase("reviewer")){
                redirect = WebPageNames.ReviewerViewPage;
            } else if(action.equalsIgnoreCase("organizer")){
                redirect = WebPageNames.OrganizerViewPage;
            }
        }
        response.sendRedirect(redirect);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }
}
